//
//  MyBranchDynamicShowBigTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by 刘应平 on 2017/7/14.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "MyBranchDynamicShowBigTableViewCell.h"

@interface MyBranchDynamicShowBigTableViewCell ()
/**  backImageView  */
@property (strong, nonatomic) UIImageView  *backImageView;
/**  header  */
@property (strong, nonatomic) UILabel  *headLine;
/**  time  */
@property (strong, nonatomic) UILabel  *time;
/**  机构  */
@property (strong, nonatomic) UILabel  *orangeLabel;


@end
@implementation MyBranchDynamicShowBigTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


/**  200  */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self addSubview:self.backImageView];
        [self.backImageView addSubview:self.headLine];
        [self addSubview:self.orangeLabel];
        [self addSubview:self.time];
        
        
        self.backImageView.sd_layout
        .topSpaceToView(self,10 * [UIScreen zj_screenHScale])
        .leftSpaceToView(self, 15 * [UIScreen zj_screenWScale])
        .rightSpaceToView(self, 15 * [UIScreen zj_screenWScale])
        .heightIs(150 * [UIScreen zj_screenHScale]);
        
        
        self.headLine.sd_layout
        .bottomEqualToView(self.backImageView)
        .leftEqualToView(self.backImageView)
        .rightEqualToView(self.backImageView)
        .heightIs(30 * [UIScreen zj_screenHScale]);
        
       
        
        self.orangeLabel.sd_layout
        .widthIs([UIScreen zj_screenWith] * 0.4)
        .heightIs(13 * [UIScreen zj_screenHScale])
        .topSpaceToView(self.backImageView,17 * [UIScreen zj_screenHScale])
        .leftEqualToView(self.backImageView);
        
        self.time.sd_layout
        .widthIs([UIScreen zj_screenWith] * 0.6 - 40 * [UIScreen zj_screenWScale])
        .heightIs(13 * [UIScreen zj_screenHScale])
        .topEqualToView(self.orangeLabel)
        .rightSpaceToView(self, 15 * [UIScreen zj_screenWScale]);
        
        
        
        UIView *under = [UIView new];
        under.backgroundColor = [UIColor themeGrayColor];
        [self addSubview:under];
        under.sd_layout.leftEqualToView(self).bottomEqualToView(self).widthIs([UIScreen zj_screenWith]).heightIs(1);
        
    }
    return self;
}

- (void)setModel:(LPDCDetailModel *)model{
    _model = model;

    NSString *image;
    if (model.IMAGEJSON.count == 0) {
        image = @"meitupain";
    }else{
        image = [model.IMAGEJSON[0] objectForKey:@"imageUrl"];
    }
    
    [self.backImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",BASEIMAGEURL,image]] placeholderImage:PlaceholderImage];
    /**  设置行距  */
    self.headLine.text = [NSString stringWithFormat:@"    %@",model.TITLE];
    
    
    self.time.text = model.PUBLISHDATE;
    self.orangeLabel.text = model.AUTHOR;
    
}

- (UILabel *)headLine{
    if (!_headLine) {
        _headLine = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor whiteColor];
            label.font = [UIFont systemFontOfSize:16 * [UIScreen zj_textFontScale]];
            label.backgroundColor = [UIColor zj_colorWithR:20 G:20 B:20 Al:0.5];
            label;
        });
    }
    return _headLine;
}


- (UILabel *)time{
    if (!_time) {
        _time = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentRight;
            label.textColor = [UIColor textBlackColor];
            label.font = [UIFont systemFontOfSize:15 * [UIScreen zj_textFontScale]];
            
            label;
        });
    }
    return _time;
}


- (UILabel *)orangeLabel{
    if (!_orangeLabel) {
        _orangeLabel = ({
            UILabel *label = [UILabel new];
            label.textAlignment = NSTextAlignmentLeft;
            label.textColor = [UIColor textGrayColor];
            label.font = [UIFont systemFontOfSize:15 * [UIScreen zj_textFontScale]];
            label;
        });
    }
    return _orangeLabel;
}

- (UIImageView *)backImageView{
    if (!_backImageView) {
        _backImageView = [UIImageView new];
        _backImageView.contentMode = UIViewContentModeScaleAspectFill;
        _backImageView.clipsToBounds = YES;
    }
    return _backImageView;
    
}

@end
